//package com.giscloud.core;
//
//
//import org.apache.commons.lang3.ArrayUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//
//@SuppressWarnings("SpringJavaAutowiringInspection") //加这个注解让IDE 不报: Could not autowire
//public class SSOInterceptor implements HandlerInterceptor {
//
//
//	private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
//
//	private static String []methods = new String[]{"GET","POST","HEAD"};
//
//	@Override
//	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		logger.debug("1、认证拦截器验证,请求地址："+request.getRequestURL()+"请求方法："+request.getMethod());
//        //安全校验
//        String method = request.getMethod();
//        if(!ArrayUtils.contains(methods,method)) {
//            logger.error("The request with Method["+method+"] was forbidden by server!");
//            response.setContentType("text/html;charset=GBK");
//            response.setCharacterEncoding("GBK");
//            response.setStatus(403);
//            response.getWriter().print("<font size=6 color=red>对不起，您的请求非法，系统拒绝响应!</font>");
//            return false;
//        }
//
//		try {
//			// 2、取到token，需要调用sso系统的服务查询用户信息。
//			HttpSession session = request.getSession();
//			logger.debug("2、认证拦截器验证session:"+session.getId());
//			if(session.getAttribute("userid") == null){
//			    return false;
//            }
//
//
//		} catch (Exception e) {
//            request.getSession().removeAttribute("sso_token");
//            request.getSession().invalidate();
//			logger.error("3、认证拦截器验证异常："+e.getMessage());
//		//	response.sendRedirect(serverDomain + loginUrl+"?callbackUrl="+url.toString()+"&code=9999&p="+commConstConfig.getSystemPrefix());
//			return false;
//		}
//		// 9、如果验证通过，放行。
//		return true;
//	}
//
//	@Override
//	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
//			throws Exception {
//	}
//
//
//	@Override
//	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
//			throws Exception {
//	}
//}
